package com.tyj.gulimall.product.web;

import com.tyj.gulimall.product.service.SkuInfoService;
import com.tyj.gulimall.product.vo.web.SkuItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.ExecutionException;

@Controller
@Slf4j
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;
    /**
     * 展示sku详情
     * @param skuId
     * @return
     */
    @RequestMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {
        SkuItemVo skuItemVo=skuInfoService.item(skuId);
        model.addAttribute("item",skuItemVo);
        log.debug("通过点击商品得到的数据="+skuItemVo);
        return "item";
    }

}
